package com.emerald.algorithm;

public class QuickUnionImprovement {
	
	private int[] id;
	
	public QuickUnionImprovement(int length){
		id = new int[length];
		for(int i=0;i<length;i++){
			id[i] = i;
		}
	}
	
	private int root(int i){
		while(i != id[i]){
			i = id[i];
		}
		return i;
	}
	
	public boolean isConnected(int p, int q){
		return root(p) == root(q);
	}
	
	public void union(int p, int q){
		int i = root(p);
		int j = root(q);
		
	}
}
